<? 
	$title="Edit category"; 
	$pageid="5";
	$accessid="a00";
	
	require("required/dbconnect.php"); 
	require("required/function.php");
	
	if(isset($_POST['btnsubmit']))
	{
		$type_name=$_POST['type_name'];
		$use_flat_rate=$_POST['use_flat_rate'];		
		$flat_rate=$_POST['flat_rate'];
		$status=$_POST['status'];			
		$id=$_POST['id'];
		
		mysql_query("update os_shipping_type set type_name='$type_name',flat_rate='$flat_rate',status='$status',use_flat_rate='$use_flat_rate' where id=$id")or die(mysql_error());
		header("Location:shipping_view_full.php?id=$id&action=1");		
	}
	
	require("required/header.php");
	
	checkAccess("allow_shipping_management",1);
	
	$id=$_GET['id'];
	
	$get_info=mysql_query("select * from os_shipping_type where id=$id");
	
	if(mysql_num_rows($get_info)==0)
	{
		echo "No record found!!";
	}
	else
	{
		

	$a=mysql_fetch_array($get_info,MYSQL_ASSOC);
	if($a['status']==0)
	{
		$slt0="selected";
		$slt1="";
		
	}
	else
	{
		$slt0="";
		$slt1="selected";
	}
	
	if($a['use_flat_rate']==0)
	{
		$fslt0="selected";
		$fslt1="";
		
	}
	else
	{
		$fslt0="";
		$fslt1="selected";
	}
	
?>
<table width="95%" cellpadding="2" cellspacing="1">

	<td valign="top">
	<table width="584">
	<tr>
		<td colspan="4"><font class="title">Edit Shipping Company</font></td>
	</tr>
	
	<form action="<?= $_SERVER['PHP_SELF'] ?>" method="post" name="frm" onSubmit="return frmValidate(this)">
	<input type="hidden" value="<?= $id ?>" name="id">
	<tr>
		<td>Company Name</td><td>:</td><td><input class="text" type="text" name="type_name" size="30" value="<?= $a['type_name'] ?>" maxlength="100"></td>
	</tr>
	<tr>
		<td>Flat Rate</td><td>:</td><td><input class="text" type="text" name="flat_rate" size="5" value="<?= $a['flat_rate'] ?>" maxlength="5"></td>
	</tr>
    <tr>
        <td>Use Flat Rate</td><td>:</td>
        <td>
            <select name="use_flat_rate" class="text">
                <option value="0" <?= $fslt0 ?>>No</option>
                <option value="1" <?= $fslt1 ?>>Yes</option>
            </select>	
        </td>
    </tr>
	<tr>
        <td>Show at website</td><td>:</td>
        <td>
            <select name="status" class="text">
                <option value="0" <?= $slt0 ?>>No</option>
                <option value="1" <?= $slt1 ?>>Yes</option>
            </select>	
        </td>
    </tr>
	
	<tr>
		<td colspan="3" align="center"><br><input type="submit" value="Update" class="button" name="btnsubmit">  <input type="button" value="Back" class="button" onclick="window.open('shipping_view_full.php?id=<?= $id ?>','_self')"><br><br></td>
	</tr>
	</form>
	</table></td>
			
</table>
<? } require("required/footer.php"); ?>

